<?php

namespace App\Controller\Admin;

use App\Controller\InsideService\BadgeLogInside;
use App\Middleware\AdminMiddleware;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\Middleware;

#[Controller(prefix: '/admin/BadgeLog'), Middleware(AdminMiddleware::class)]
class BadgeLogController extends BaseController {

    /**
     * 获取列表
     * @return array
     * @throws \Exception
     */
    #[GetMapping(path: 'index')]
    public function index(): array {
        $userDataArr = $this->uInfo();
        $limit = $this->request->query('size', config('apiadmin.admin_list_default'));
        $game_hash = $this->request->query('game_hash', '');
        $openid = $this->request->query('openid', '');
        $hero_id = $this->request->query('hero_id', '');
        $type = $this->request->query('type', 0);
        $item_id = $this->request->query('item_id', '');
        $date = $this->request->query('date', '');
        $page = $this->request->query('page', 1);

        if (empty($game_hash)) {
            $game_hash = $userDataArr['user_data']['bind_games'];
        }

        return (new BadgeLogInside())->setCode($userDataArr['connection_code'])->index([
            'page'      => $page,
            'openid'    => $openid,
            'hero_id'   => $hero_id,
            'type'      => $type,
            'item_id'   => $item_id,
            'date'      => $date,
            'size'      => $limit,
            'game_hash' => $game_hash
        ]);
    }

}